const mysql = require("mysql");
var client = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "123456",
  database: "myego", //所在数据库名
  //如果报错在mysql中把密码改下
  // ALTER USER 'root'@'localhost'IDENTIFIED WITH mysql_native_password BY '密码';
});

function sqlFn(sql, arr, callback) {
  client.query(sql, arr, function (error, result) {
    // console.log(result)
    if (error) {
      console.log(error);
      return;
    }
    // 回调函数
    callback(result);
  });
}

module.exports = sqlFn;
